package com.acme.bankapp.domine.bank;

public class CheckingAccount extends AbstractAccount {
    private double overdraft;

    public double getOverdraft() {
        return overdraft;
    }

    // define constructor public CheckingAccount
    public CheckingAccount(final int id, final double amount, final double overdraft) {
        super(id, amount);
        this.overdraft = overdraft;
    }

    @Override
    public int withdraw(double amount) {
        if(getBalance() + overdraft >= amount){
            setBalance(getBalance() - amount);
            return 0;
        }
        else {
            System.out.println("Error CheckingAccount: balance + overdraft < amount");
            return -1;
        }
    }

    @Override
    public double maximumAmountToWithdraw() {
        return getBalance() + overdraft;
    }
}
